<template>
  <div class="dashboard-editor-container">

    <panel-group />

   <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
     <line-chart :chartData="line20" v-if="line20 != null"/>
   </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart :chartData="line29" v-if="line29 != null"/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart :chartData="line30" v-if="line30 != null"/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart :chartData="line31" v-if="line31 != null"/>
        </div>
      </el-col>
    </el-row>


  </div>
</template>

<script>
import { getChart} from "@/api/sys/chart";
import PanelGroup from './dashboard/PanelGroup'
import LineChart from '@/components/Charts/LineChart.vue'
import PieChart from '@/components/Charts/PieChart.vue'

export default {
  name: 'Index',
  components: {
    PanelGroup,
    LineChart,
    PieChart
  },
  data() {
    return {
      line20: null,
      line29: null,
      line30: null,
      line31: null
    }
  },
  created() {
    getChart(20).then(response => {
      this.line20 = response.data;
    });
    getChart(29).then(response => {
      this.line29 = response.data;
    });
    getChart(30).then(response => {
      this.line30 = response.data;
    });
    getChart(31).then(response => {
      this.line31 = response.data;
    });
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
